import { defineConfig } from '@rsbuild/core'
import { pluginSass } from '@rsbuild/plugin-sass'
import { pluginVue } from '@rsbuild/plugin-vue'

export default defineConfig({
  plugins: [pluginVue(), pluginSass()],
  source: {
    alias: {
      '@views': './src/views',
      '@components': './src/components',
      '@store': './src/store',
      '@assets': './src/assets',
      '@utils': './src/utils',
      '@': './src'
    }
  },
  server: {
    proxy: [
      {
        context: ['/auth', '/api'],
        target: 'http://localhost:3001',
        pathRewrite: { '^/api': '' },
        bypass: function (req, res, proxyOptions) {
          // console.log(req.headers.accept)
          if (req.headers.accept.indexOf('html') !== -1) {
            console.log('Skipping proxy for browser request.')
            return '/404'
          }
        }
      }
    ]
  }
})
